// 引入 wx.request 方法需要的 URL
const apiUrl = 'http://127.0.0.1:5000/questions';

Page({
  data: {
    questions: [], // 问题列表
  },

 whatknow(){
    wx.navigateTo({
        url:'/pages/whatknow/whatknow'
    });
    },
 whatknowtwo(){
        wx.navigateTo({
            url:'/pages/whatknowtwo/whatknowtwo'
        });
        },
whatknowthree(){
        wx.navigateTo({
            url:'/pages/whatknowthree/whatknowthree'
        });
        },
whatknowfour(){
         wx.navigateTo({
            url:'/pages/whatknowfour/whatknowfour'
     });
        },
whatknowfive(){
        wx.navigateTo({
            url:'/pages/whatknowfive/whatknowfive'
        });
         },

  onLoad: function () {
    wx.request({
      url: apiUrl,
      success: (res) => {
        const questionArr = res.data;
        // 保存问题列表
        this.setData({
          questions: questionArr,
        });
      },
    });
  },
  showAnswer: function (e) {
    const index = e.currentTarget.dataset.index;
    const questions = this.data.questions;
    questions[index].showAnswer = true;
    // 更新问题列表
    this.setData({
      questions: questions,
    });
  },
});